package com.bh.weapp.controller.common;

import com.bh.common.annotation.RepeatSubmit;
import com.bh.common.core.controller.BaseController;
import com.bh.common.core.domain.AjaxResult;
import com.bh.common.utils.StringUtils;
import com.bh.kysys.domain.JcSysOrganization;
import com.bh.kysys.domain.JcZone;
import com.bh.kysys.service.IJcSysOrganizationService;
import com.bh.kysys.service.IJcZoneService;
import com.bh.kysys.vo.JcSysOrganizationInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 行政区域Controller
 *
 * @author slx
 * @date 2023-03-24
 */
@Api(tags = {"COMMON外部用户用户信息接口"})
@RestController
@RequestMapping("/api/common/org")
public class JcOrgApiController extends BaseController {

    @Autowired
    private IJcSysOrganizationService jcSysOrganizationService;

    /**
     * 查询行政区域
     */
    @ApiOperation("查询发货组织单位")
    @GetMapping("/list")
    public AjaxResult getList() {
        JcSysOrganization params = new JcSysOrganization();
        List<JcSysOrganizationInfoVo> infoVos = new ArrayList<>();
        List<JcSysOrganization> jcSysOrganization = jcSysOrganizationService.selectJcSysOrganizationList(params);
        for (JcSysOrganization org : jcSysOrganization) {
            if ("root".equals(org.getName())) {
                continue;
            }
            JcSysOrganizationInfoVo infoVo = new JcSysOrganizationInfoVo();
            infoVo.setName(org.getName());
            infoVo.setDetaileAddress(org.getAddress());
            infoVo.setAddress(org.getAddress());
            infoVo.setContactperson(org.getPrincipal());
            infoVo.setIphone(org.getDescription());
            infoVo.setLtl(org.getLatitude());
            infoVos.add(infoVo);
        }
        return AjaxResult.success(infoVos);
    }
}
